import { createWebHashHistory, createRouter } from 'vue-router'

import HomeView from './HomeView.vue'
import AboutView from './AboutView.vue'
import CateView from './CateView.vue'
import DetailView from './DetailView.vue'
import VideoView from './VideoView.vue'
import VideoDetail from './VideoDetail.vue'
import PriceView from './PriceView.vue'
import FileView from './FileView.vue'
import FileListView from './FileListView.vue'
import FileDetailView from './FileDetailView.vue'
import MaterialView from './MaterialView.vue'

const routes = [
  { path: '/', component: HomeView, meta: { title: '首页'} },
  { path: '/about', component: AboutView, meta: { title: '关于我们'} },
  { path: '/cate', component: CateView, meta: { title: '问题解答'} },
  { path: '/detail', component: DetailView, meta: { title: '详情'} },
  { path: '/video', component: VideoView, meta: { title: '视频帮助'} },
  { path: '/videoDetail', component: VideoDetail, meta: { title: '视频详情'} },
  { path: '/price', component: PriceView, meta: { title: '材料参考价查询'}},
  { path: '/file', component: FileView, meta: { title: '文件规范'}},
  { path: '/fileList', component: FileListView, meta: { title: '部颁文件'}},
  { path: '/fileDetail', component: FileDetailView, meta: { title: '文件详情'}},
  { path: '/material', component: MaterialView, meta: { title: '次要材料'}}
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})
export default router